﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Freshbooks.XmlSerializers;

namespace Freshbooks.Model
{
    [FreshbooksSerialization(Name = "recurring")]
    public class Recurring
    {
        [FreshbooksSerialization(Name = "recurring_id")]
        public int RecurringId { get; set; }

        [FreshbooksSerialization(Name = "frequency")]
        public string Frequency { get; set; }

        [FreshbooksSerialization(Name = "occurrences")]
        public int Occurrences { get; set; }

        [FreshbooksSerialization(Name = "stopped")]
        public bool Stopped { get; set; }

        [FreshbooksSerialization(Name = "client_id")]
        public int ClientId { get; set; }

        [FreshbooksSerialization(Name = "contacts")]
        public List<RecurringContact> Contacts { get; set; }

        [FreshbooksSerialization(Name = "staff_id")]
        public int StaffId { get; set; }

        [FreshbooksSerialization(Name = "organization")]
        public string Organization { get; set; }

        [FreshbooksSerialization(Name = "first_name")]
        public string NameFirst { get; set; }

        [FreshbooksSerialization(Name = "last_name")]
        public string NameLast { get; set; }

        [FreshbooksSerialization(Name = "p_street1")]
        public string Street1 { get; set; }

        [FreshbooksSerialization(Name = "p_street2")]
        public string Street2 { get; set; }

        [FreshbooksSerialization(Name = "p_city")]
        public string City { get; set; }

        [FreshbooksSerialization(Name = "p_state")]
        public string State { get; set; }

        [FreshbooksSerialization(Name = "p_country")]
        public string Country { get; set; }

        [FreshbooksSerialization(Name = "p_code")]
        public string PostalCode { get; set; }

        [FreshbooksSerialization(Name = "vat_name")]
        public string VatName { get; set; }

        [FreshbooksSerialization(Name = "vat_number")]
        public string VatNumber { get; set; }

        [FreshbooksSerialization(Name = "po_number")]
        public string PONumber { get; set; }

        [FreshbooksSerialization(Name = "status")]
        public string Status { get; set; }

        [FreshbooksSerialization(Name = "amount")]
        public float Amount { get; set; }

        [FreshbooksSerialization(Name = "currency_code")]
        public string CurrencyCode { get; set; }

        [FreshbooksSerialization(Name = "language")]
        public string Language { get; set; }

        [FreshbooksSerialization(Name = "date")]
        public DateTime Date { get; set; }

        [FreshbooksSerialization(Name = "notes")]
        public string Notes { get; set; }

        [FreshbooksSerialization(Name = "terms")]
        public string Terms { get; set; }

        [FreshbooksSerialization(Name = "discount")]
        public float Discount { get; set; }

        [FreshbooksSerialization(Name = "return_uri")]
        public string ReturnUri { get; set; }

        [FreshbooksSerialization(Name = "send_snail_mail")]
        public bool SendSnailMail { get; set; }

        [FreshbooksSerialization(Name = "send_email")]
        public bool SendEMail { get; set; }

        [FreshbooksSerialization(Name = "folder")]
        public string Folder { get; set; }

        [FreshbooksSerialization(Name = "autobill")]
        public RecurringAutobill Autobill { get; set; }

        [FreshbooksSerialization(Name = "lines")]
        public List<Line> Lines { get; set; }

        [FreshbooksSerialization(Name = "autobill")]
        public class RecurringAutobill
        {
            [FreshbooksSerialization(Name = "gateway_name")]
            public string GatewayName { get; set; }

            [FreshbooksSerialization(Name = "card")]
            public RecurringCard Card { get; set; }

            [FreshbooksSerialization(Name = "card")]
            public class RecurringCard
            {
                [FreshbooksSerialization(Name = "number")]
                public string Number { get; set; }

                [FreshbooksSerialization(Name = "name")]
                public string name { get; set; }

                [FreshbooksSerialization(Name = "expiration")]
                public CardExpiration Expiration { get; set; }

                [FreshbooksSerialization(Name = "expiration")]
                public class CardExpiration
                {
                    [FreshbooksSerialization(Name = "month")]
                    public string Month { get; set; }

                    [FreshbooksSerialization(Name = "year")]
                    public string Year { get; set; }
                }
            }
        }

        [FreshbooksSerialization(Name = "contact")]
        public class RecurringContact
        {
            [FreshbooksSerialization(Name = "contact_id")]
            public int ContactId { get; set; }
        }
    }

    [FreshbooksSerialization(Name = "response")]
    public class Recurrings
    {
        [FreshbooksSerialization(Name = "ok", Attribute = true)]
        public string Ok { get; set; }

        [FreshbooksSerialization(Name = "page", Attribute = true)]
        public int Page { get; set; }

        [FreshbooksSerialization(Name = "per_page", Attribute = true)]
        public int PerPage { get; set; }

        [FreshbooksSerialization(Name = "pages", Attribute = true)]
        public int Pages { get; set; }

        [FreshbooksSerialization(Name = "total", Attribute = true)]
        public int Total { get; set; }
    }
}
